<?php
class Project extends AppModel {
  var $name = 'Project';
  var $primaryKey = 'id';
  
  // musi byt required ked mam nejaky iny rule?
  // TODO: department a leader
  var $validate = array(
    'name' => array(
      'rule'    => array('between', 2, 200),
      'required' => true,
      'message'  => 'Name requires Minimum 2 and Maximum 200 characters'
    ),
    'annotation' => array(
      'rule'    => array('between', 1, 250),
      'required' => true,
      'allowEmpty' => false,
      'message'  => 'Annotation can\'t be empty'
    ),
    'budget' => array(
      'rule' => 'numeric',
      'required' => true,
      'message'  => 'Budget must be a numeric value'
    ),
    /*preco to nie je boolean v DB?*/
    'is_deleted' => array(
      'rule'    => array('boolean'),
      'required' => true,
      'message'  => 'Numbers 0 or 1 only'
    ),
    // nefunguje ta kontrola na date, ale v DB je to spravne
    /*'start' => array(
      'rule'    => 'date',
      'required' => true,
      'message'  => 'Correct start date only'
    ),
    'end' => array(
      'rule'    => 'date',
      'required' => true,
      'message'  => 'Correct end date only'
    )*/
  );
  
  var $belongsTo = array(
    'Leader' => array(
      'className' => 'Person',
      'foreignKey' => 'leader_id'
    ),
    'Department' => array(
      'className' => 'Department',
      'foreignKey' => 'department_id'
    )
  );
  
  var $hasAndBelongsToMany = array(
    'Person'
  );
}
?>